<?php
namespace app\admin\controller;

use app\common\model\CompanyConfession as CompanyConfessionModel;
use app\common\model\Company as CompanyModel;
/**
 * 忏悔控制器
 * Class Companyxuyuan
 * @package app\index\controller
 */
class Companyconfession extends Base
{
    /**
     * [index  忏悔列表]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function index()
    {
        $model = new CompanyConfessionModel;
        $cmodel = new CompanyModel;
        $param = input('param.');
        $this->getPageAndSize($param);
        $map = [];
        $user = $this->user;
        try{
            $field = 'c.id,c.mid,c.content,c.comid,c.create_time,c.status,c.reply,m.tel,m.username,m.img';
            $count = $model->getCount($map);//满足条件的总数
            $allpage = intval(ceil($count / $this->size));//总页数
            $lists = $model->getlist($map,$this->from, $this->size,$field);
            foreach($lists as &$v){
                $http = substr($v['img'],0,4);
                if($http != 'http'){
                    $v['img'] = config('domain_name').$v['img'];
                }
                $company = $cmodel->findData($v['comid'],'id','comname');
                $v['comname'] = $company['comname'];
            }
        }catch(\Exception $e){
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        writelog('查看忏悔列表',0,$user);
        return admin_json(1,'获取成功',[
            'count' => $count,//总记录数
            'allpage' => $allpage,  //总页数
            'lists' => $lists,  //列表数据
        ]);
    }
}